package com.service.web.controller.system;

import javax.servlet.http.HttpServletResponse;

import com.service.common.core.domain.entity.ClassScore;
import com.service.common.utils.poi.ExcelUtil;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.service.common.annotation.Log;
import com.service.common.core.controller.BaseController;
import com.service.common.core.domain.AjaxResult;
import com.service.common.enums.BusinessType;
import com.service.system.service.IClassScoreService;
import com.service.common.core.page.TableDataInfo;

import java.util.List;

/**
 * 班级评分Controller
 *
 * @author service
 * @date 2024-05-02
 */
@RestController
@RequestMapping("/system/class_score")
public class ClassScoreController extends BaseController
{
    @Autowired
    private IClassScoreService classScoreService;

    /**
     * 查询班级评分列表
     */
//    @PreAuthorize("@ss.hasPermi('system:score:list')")
    @GetMapping("/list")
    public TableDataInfo list(ClassScore classScore)
    {
        startPage();
        List<ClassScore> list = classScoreService.selectClassScoreList(classScore);
        return getDataTable(list);
    }

    /**
     * 导出班级评分列表
     */
    @PreAuthorize("@ss.hasPermi('system:score:export')")
    @Log(title = "班级评分", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ClassScore classScore)
    {
        List<ClassScore> list = classScoreService.selectClassScoreList(classScore);
        ExcelUtil<ClassScore> util = new ExcelUtil<ClassScore>(ClassScore.class);
        util.exportExcel(response, list, "班级评分数据");
    }

    /**
     * 获取班级评分详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:score:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(classScoreService.selectClassScoreById(id));
    }

    /**
     * 新增班级评分
     */
    @PreAuthorize("@ss.hasPermi('system:score:add')")
    @Log(title = "班级评分", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ClassScore classScore)
    {
        return toAjax(classScoreService.insertClassScore(classScore));
    }

    /**
     * 修改班级评分
     */
    @PreAuthorize("@ss.hasPermi('system:score:edit')")
    @Log(title = "班级评分", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ClassScore classScore)
    {
        return toAjax(classScoreService.updateClassScore(classScore));
    }

    /**
     * 删除班级评分
     */
    @PreAuthorize("@ss.hasPermi('system:score:remove')")
    @Log(title = "班级评分", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(classScoreService.deleteClassScoreByIds(ids));
    }
}
